import random

if __name__ == '__main__':
    import sys
    sp = [0.05, 0.1, 1]
    if len(sys.argv) != 2:
        print './this inputdata'
        exit(1)
    fname = sys.argv[1]
    f = open(fname, 'r')

    ftrain = open(fname+'.train', 'wb')
    fdev = open(fname+'.dev', 'wb')
    ftest = open(fname+'.test', 'wb')

    for line in f:
        num = random.uniform(0, 1)
        if num <= sp[0]:
            fdev.write(line)
        elif num <= sp[1]:
            ftest.write(line)
        else:
            ftrain.write(line)
